package fire.combat;

import java.util.ArrayList;

import util.OOMLoad;
import fire.Main;
import fire.chacracter.Enemy;
import fire.chacracter.Player;
import fire.pet.Pet;
import fire.room.FactoryMap;
import fire.room.Map;

public class CombatMap {

	private static CombatPet combatPet;
	private static gozillaPet playerPet;
	private static AttackButton attackButton;
	private static Map oldMap;
	private static double lastX;
	private static double lastY;
	private static Player player;

	public static void create(Main main, Enemy enemy, Map map) {
		oldMap = map;
		main.setBGImage(map.getName() + "_combat");
		main.setView(Main.VIEW_LOADING);
		Player p = Player.getPlayer();
		player = p;
		lastX = p.x;
		lastY = p.y;
		p.setPos(-1000, -1000);
		p.suspend();
		main.setPFSize(65, 48);
		main.setView(Main.VIEW_START_GAME);
		ArrayList<Pet> petList = enemy.getPetList();
		enemy.remove();
		playerPet = new gozillaPet(100, 500);
		for (int i = 0; i < petList.size(); i++) {
			Pet pet = petList.get(i);
			combatPet = new CombatPet("Pet" + i, true, 500, 400 - i * 150, 777,
					pet.getImage(), pet);
		}
		playerTurn(playerPet, combatPet);
	}

	private static void playerTurn(gozillaPet playerPet2, CombatPet combatPet2) {
		attackButton = new AttackButton(playerPet2, combatPet2);
	}

	public static AttackButton getAttackButton() {
		return attackButton;
	}

	public static void setAttackButton(AttackButton attackButton) {
		CombatMap.attackButton = attackButton;
	}

	public static CombatPet getCombatPet() {
		return combatPet;
	}

	public static void setCombatPet(CombatPet combatPet) {
		CombatMap.combatPet = combatPet;
	}

	public static gozillaPet getPlayerPet() {
		return playerPet;
	}

	public static void setPlayerPet(gozillaPet playerPet) {
		CombatMap.playerPet = playerPet;
	}

	public static void win() {
		playerPet.remove();
		combatPet.remove();
		attackButton.remove();
		Main.changeMap(oldMap);
		player.setPos(lastX, lastY);
	}

	public static void lose() {
		Main.changeMap(FactoryMap.mapList.get("startgame"));
	}

}
